package com.upbos.school;

import com.upbos.entity.App;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Service
public class SchoolService {

	@Resource
	private SchoolDao schoolDao;

	/**
	 * 查询应用列表
	 * @param name 应用名称
	 * @return 应用列表
	 */
	public List<App> listApp(String name) {
		return schoolDao.listApp(name);
	}

	/**
	 * 保存应用信息
	 * @param app 应用信息
	 */
	@Transactional(rollbackFor = Exception.class)
	public void saveApp(App app) {
	    if(app.getId() == null || "".equals(app.getId())) {
	    	// 插入应用信息
	    	schoolDao.insertApp(app);
        }else {
	    	// 更新应用信息
            schoolDao.updateApp(app);
        }
	}

	/**
	 * 根据应用ID删除应用信息
	 * @param app 应用id
	 */
	@Transactional(rollbackFor = Exception.class)
	public void deleteApp(App app) {
		schoolDao.deleteApp(app);
	}
}
